<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
	<head>
	 <base href="<%=basePath%>">
		<link href="themes/css/ui.common.css" rel="stylesheet"
			type="text/css" />
		<link href="themes/css/ui.child.css" rel="stylesheet"
			type="text/css" />
		<link href="themes/css/ui.tips.css" rel="stylesheet"
			type="text/css" />
		<link href="style/jquery_ui/jquery-ui-1.8.custom.css"
			rel="stylesheet" type="text/css" />
    <link id="skin_css" rel="stylesheet" type="text/css" href=" themes/css/ui.c.blue.css" />
    <script src=" Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script src=" Scripts/jquery-ui-1.8.custom.min.js" type="text/javascript"></script>
    <script src=" Scripts/jquery.json-2.2.min.js" type="text/javascript"></script>
 
    <script src=" Scripts/ui.admincp.js" type="text/javascript" charset="UTF-8"></script>
    <script src=" Scripts/ui.tips.js" type="text/javascript"></script>
    <script src=" Scripts/ui.default.js" type="text/javascript" charset="UTF-8"></script>
 
	<script type="text/javascript" src="Scripts/ui.clientDateHelper.js"></script>

	<script type="text/javascript"
			src="Scripts/ui.dialogFormHelper.js"></script>
	<SCRIPT type="text/javascript">
			var searching = false;
				$(function(){
					$("#link_page_prev,#link_page_next").click(function(){
			    		var currentPage = $(this).attr("currentPage");
			    	 
			    		goToPage(currentPage);
			    	}); 
			    	
			    	$("#searchButton").click(function(){
						searching=true;
			    		goToPage(1);
			    	});
			    	
			    	initSearch();
			    	registeRowFuncButton();
				});
				
				function initSearch()
				{
				
				}
			 
				function goToPage(currentPage)
				{
				  	var states = $("#states").val();  
					location.href = "messageInfo!query.action?currpage="+currentPage+"&states="+states;
				}
	</SCRIPT>
	<script type="text/javascript">
	 
      $(function () { 
            $(".ui-news-title").click(function () {
                if( $(this).attr("current")=="true")
                {
                 	 var content =  $(this).next(".ui-news-content").slideToggle();
                }else
                {
                    $(".ui-news-title").attr("current","false");
                   	$(".ui-news-content").slideUp();
                    $(this).attr("current","true");
                   	$(this).next(".ui-news-content").slideDown();
                }
                changeState($(this));
          });
 
        });
        
        function changeState(obj){ 
				var messageId = obj.attr("messageId");
               	var state = obj.attr("messageState")||"0";	
               	if(state=="0"){
               		$.post("messageInfo!read.action?messageId="+messageId,null,function(callBack){	 
						obj.find("img.message-state-icon:first").attr("src","themes/icons/mailState1.png");		
					},"text");  		
               		obj.attr("messageState","1");
               	} 
        }
        
       	function checkAll(str)
				{
　 					var items = document.getElementsByName(str);　
　					var totalNum = items.length;
　 					for (var i=0; i<totalNum; i++)
　 					items[i].checked = window.event.srcElement.checked;
				}
		function deleteAll(str)
				{
					var isTo = checkDeleteAll("消息");
					
				//	if(isTo==false)
  				//	return ;
　 					var items = document.getElementsByName(str);　 //获取所有复选框
　					var totalNum = items.length;　 //获取复选框的个数
					var delStr = "";
　 					for (var i=0; i<totalNum; i++){
　 						if(items[i].checked == true){
							delStr += items[i].value + ","; 
						}
					}
					delStr = delStr.substring(0, delStr.length -1);	
					location.href= "messageInfo!deleteMore.action?messageIds="+delStr+"&currpage="+${currpage};
				}
    </script>
    <style type="text/css">
        body
        {
            font-size: 12px;
        }
        
        .ui-news-title   
        {
            background-color: #C8D6EF;
            cursor: hand;
            padding: 5px;
            text-align: right;
        }
        
        .ui-news-innerTitle
        {
            float: left;
            overflow: hidden;
        }
        
        .ui-news-content
        {
            text-indent: 26px;
            background-color: #CFDFF7;
            padding: 5px;
            display:none;
        }
        
        .ui-news-barnar
        {
        }
        
        .ui-news-entity
        {
            border-bottom: 1px dashed #EFFBF5;
        }
        .message-state-icon
        {
        }
        
        .ui-news-entity-title
        {
            padding: 5px;
            font-size: larger;
        }
        
        .ui-news-postor
        {
        	font-weight:bolder;
        }
        
        #ui-news-latestList
        {
            width: 100%;
        }
    </style>
</head>
	<body>
	<div class="PageChild_Title">
			<img src=" themes/images/default/icons/archives.png"
				class="PageChild_Tbtnpic" />
			<span class="PageChild_separate"></span>
			<span class="PageChild_TbtnText"><h2>
					消息列表
				</h2>
			</span>
			<span class="PageChild_separate"></span>
			<div id="marker" class="red-tips">
			</div>
			<div class="clear">
			</div>
	</div>
		<!-- 搜索栏 -->
		<div class="PageChild_Where">
			<table style="height: 60px;" border="0" cellpadding="0"
				cellspacing="0">
				<tr>
					<td class="mtd">
						&nbsp;消息状态:<s:select id="states" theme="simple" list="#{1:'已读',0:'未读'}"  label="abc" listKey="key" listValue="value"  headerKey="-10" headerValue="--选择消息状态--" value="states"></s:select>	
				</td>
				<td>
						<input type="submit" name="btn_Serach" value="搜索" id="btn_Serach" class="o-btn" style="font-size:12px" onclick="goToPage(1)" />
				</td>
				</tr>
				<tr>
					<td colspan="5">
						&nbsp;
						<span id="lbl_list_count">共有 <b>${count}</b>条消息。</span>
					</td>
				</tr>
			</table>
		</div>
		<!-- 搜索栏结束 -->
		<div id="ui-news-latestList">
		<input id="Chk_All" type="checkbox" name="Chk_All"
								onclick="checkAll('Chk_Num')" />删除所有
			<s:if test="list != null && list.size != 0">
			<s:iterator value="list" var="item" status="no"> 
        	<div class="ui-news-entity" style="width:98%">
         		<div class="ui-news-title" messageId="${item.messageId }" messageState="${item.states}" current="false" title="展开/关闭详情..">
                <span class="ui-news-innerTitle">
                <span title="${item.messageId}"><input id="Chk_Num" type="checkbox"
										name="ReptShow$ctl01$Chk_Num" value="${item.messageId}" /></span>
                <s:if test="#item.states==0">
					<img class="message-state-icon" src="themes/icons/mailState0.png"/>
				</s:if>
				<s:else>
					<img class="message-state-icon" src="themes/icons/mailState1.png"/>
				</s:else>     
                <s:property value="#no.count" />
                .${item.title}</span>
                <span class="ui-news-barnar" title="发布时间"><s:date name="#item.createTime" format="yyyy-MM-dd HH:mm" /></span>
         		</div> 
         		<div class="ui-news-content">
      			${item.contents}
      			<br/><br/>
      			</div>
      		</div>
            </s:iterator>
            </s:if><s:else>
                <div class="ui-news-entity" style="width:98%">
         		<div class="ui-news-title" current="false" title="展开/关闭详情..">
                <span class="ui-news-innerTitle"></span>
         		</div> 
         		<div class="ui-news-content">
      			暂无消息
      			<br/><br/>
      			</div>
      		</div>
            </s:else>
        </div>

		<!--分页导航开始-->
		<div id="divTopPageNavi" class="list_r_title_text3">
				<!--分页导航开始-->
				<s:if test="currpage<=1">
					<span class='list_r_title_text3a'> <img
							src="themes/images/default/page_up_gray.gif"></img>
					</span>

				</s:if>
				<s:else>
					<span class='list_r_title_text3a'> <a name="link_page_prev"
						id="link_page_prev" href="javascript:void(0);"
						currentPage="${currpage-1}"> <img
								src="themes/images/default/page_up.gif"></img>
					</a> </span>
				</s:else>
				<span class='list_r_title_text3b'> 第${currpage
					}页/共${totalpage }页 </span>
				<s:if test="currpage>=totalpage">
					<span class='list_r_title_text3a'> <img
							src="themes/images/default/page_down_gray.gif"></img>
					</span>
				</s:if>
				<s:else>
					<span class='list_r_title_text3a'> <a name="link_page_next"
						id="link_page_next" href="javascript:void(0);"
						currentPage="${currpage+1 }"> <img
								src="themes/images/default/page_down.gif"></img>
					</a> </span>
				</s:else><span id="goToPageTextArea"><input type="text" id="goPageNum" class="easyui-numberbox" id="goPageNum" max="${totalpage}" min="1"/> <input type="button" id="turnToPageButton" value="GO"/></span>
			</div>
		<!--分页导航结束-->
		<div>
			<input type="button" name="btn_Delete" class="o-btn SubmitButton"
				value="删 除" id="btn_Delete"
				onclick="deleteAll('ReptShow$ctl01$Chk_Num')" />
			</div>
	</body>
</html>
